<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 小夏 < 449134904@qq.com>
// +----------------------------------------------------------------------
namespace plugins\qbt_custom_model\validate;

use think\Validate;

class AdminQbtCustomModelValidate extends Validate
{
    protected $rule = [
        // 用|分开
        'model_name' => 'require|max:30',
        'model_tabname' => 'require|max:30|regex:[a-zA-Z][a-zA-Z0-9_]+|unique:model',
        //'model_app'              => 'require',
        'model_controller' => 'require|unique:model',
    ];

    protected $message = [
        'model_name.require' => "模型名称不能为空！",
        'model_name.max' => "模型名称长度不能超过30个字符！",
        'model_tabname.require' => "模型对应数据表不能为空!",
        'model_tabname.max' => "模型对应表名长度不能超过30个字符！",
        'model_tabname.regex' => "模型表必须以字母开头，字母或数字或下划线组合",

        //'model_app.require'        => "应用不能为空！",
        'model_controller.require' => "控制器不能为空！",
        'model_tabname.unique' => "数据表已存在！",
    ];

    //验证场景
    protected $scene = [
        'edit' => ['model_tabname' => 'require|max:30|regex:[a-zA-Z][a-zA-Z0-9_]+'],
    ];


}